package forminrecipe.data;

import javax.swing.DefaultListModel;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

public class IngredientsTableModel extends AbstractTableModel {
	private DefaultListModel itemList= new DefaultListModel();
	private DefaultListModel quantityList= new DefaultListModel();
	private DefaultListModel unitsList= new DefaultListModel();
	private int columbCount = 4;
	public IngredientsTableModel(){
	}
	public String getColumnName(int col) {
        return constants.ingredientsTableHeadings[col];
    }

	
	public void addRow(String quantity, String unit, String item){
		itemList.addElement(item);
		quantityList.addElement(quantity);
		unitsList.addElement(unit);
	}


	@Override
	public int getColumnCount() {
		// TODO Auto-generated method stub
		return columbCount;
	}


	@Override
	public int getRowCount() {
		// TODO Auto-generated method stub
		return itemList.getSize();
	}


	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		// TODO Auto-generated method stub
		if(columnIndex == 0){
			return "+";
		}else if(columnIndex == 1){
			return quantityList.getElementAt(rowIndex);
		}else if(columnIndex == 2){
			return unitsList.getElementAt(rowIndex);
		}else if(columnIndex == 3){
			return itemList.getElementAt(rowIndex);
		}
		else{
			return null;
		}
	}

}
